#include "XMLParameterLoader.h"
#include "CommonApps.h"
#include <stdlib.h>

HeuristicParams* XMLParameterLoader::load(char* filename)
{
	TiXmlDocument xmlDocument = TiXmlDocument();
	xmlDocument.LoadFile(filename);
	if (xmlDocument.Error())
	{
		const char* errordesc = xmlDocument.ErrorDesc();
		int x;
		x = 10;
	}
	HeuristicParams* heuristicParams = new HeuristicParams();
	TiXmlElement* rootElement = xmlDocument.RootElement();
	float val1 = getParamterValue(rootElement, "Param1");
	float val2 = getParamterValue(rootElement, "Param2");
	return heuristicParams;
}

float XMLParameterLoader::getParamterValue(const TiXmlElement* rootElement, const char* paramName)
{
	const TiXmlElement* elem = rootElement->FirstChildElement(paramName);
	const char* text = elem->GetText();
	double val = atof(text);
	return (float)val;
}